from autoTest_ceshopAdmin.utils.log_util import logger


def assert_util(expectRes,compare,actualRes):
    try:
        logger.info(f"开始断言：{expectRes} {compare} {actualRes}")
        if compare == "in":
            assert expectRes in actualRes
        elif compare == "==":
            assert expectRes == actualRes
        elif compare == ">":
            assert expectRes > actualRes
        elif compare == ">=":
            assert expectRes >= actualRes
        elif compare == "<":
            assert expectRes < actualRes
        elif compare == "<=":
            assert expectRes <= actualRes
        elif compare == "!=" or compare == "<>":
            assert expectRes != actualRes
        else:
            logger.error("您输入的对比方式有误")
            raise
        logger.info('断言成功 \n')
    except Exception as e:
        logger.error(f"断言失败：\n {e}\n")
        raise